package com.emm.yixun.mobile.adapter;

import java.util.ArrayList;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.emm.yixun.mobile.R;
import com.emm.yixun.mobile.model.NoticeModel;

public class NoticeAdaptercompanynew extends BaseAdapter {

	Context context;

	ArrayList<NoticeModel> name;

	public NoticeAdaptercompanynew(Context context, ArrayList<NoticeModel> name) {
		this.context = context;
		this.name = name;
	}

	public void GetDate(ArrayList<NoticeModel> name) {
		this.name = name;
		notifyDataSetChanged();
	}

	@Override
	public int getCount() {
		return name == null ? 0 : name.size();
	}

	@Override
	public Object getItem(int position) {
		return name == null ? null : name.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHd v = null;
		if (convertView == null) {
			convertView = LayoutInflater.from(context).inflate(R.layout.notice_item, null);
			v = new ViewHd();
			v.drop = (TextView) convertView.findViewById(R.id.drop);
			v.title = (TextView) convertView.findViewById(R.id.title);
			v.time = (TextView) convertView.findViewById(R.id.times);
			v.content = (TextView) convertView.findViewById(R.id.contents);
			convertView.setTag(v);
		} else {
			v = (ViewHd) convertView.getTag();
		}
		if (name.get(position).isIsselect()) {
			v.drop.setText("");
		} else {
			v.drop.setText("●");
		}
		v.title.setText(name.get(position).getTitle());
		v.time.setText(name.get(position).getTimes());
		v.content.setText(name.get(position).getContents());
		return convertView;
	}

	public static class ViewHd {
		TextView drop;

		TextView title;

		TextView time;

		TextView content;
	}

}
